<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="tvProgram" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{tvProgramHome.managed ? 'Edit' : 'Add'} Tv program</f:facet>




            <s:decorate id="dateTimeField" template="layout/edit.xhtml">
                <ui:define name="label">Date time</ui:define>
                <rich:calendar id="dateTime"
                       required="true"
                          value="#{tvProgramHome.instance.dateTime}" datePattern="MM/dd/yyyy hh:mm a"/>
            </s:decorate>


            <s:decorate id="nameField" template="layout/edit.xhtml">
                <ui:define name="label">Name</ui:define>
                <h:inputText id="name"
                           size="100"
                      maxlength="100"
                          value="#{tvProgramHome.instance.name}">
                    <a:support event="onblur" reRender="nameField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="shortDescriptionField" template="layout/edit.xhtml">
                <ui:define name="label">Short description</ui:define>
                <h:inputTextarea id="shortDescription"
                               cols="80"
                               rows="2"
                              value="#{tvProgramHome.instance.shortDescription}"/>
            </s:decorate>


            <s:decorate id="longDescriptionField" template="layout/edit.xhtml">
                <ui:define name="label">Long description</ui:define>
                <h:inputTextarea id="longDescription"
                               cols="80"
                               rows="3"
                              value="#{tvProgramHome.instance.longDescription}"/>
            </s:decorate>


            <s:decorate id="idField" template="layout/edit.xhtml">
                <ui:define name="label">Id</ui:define>
                <h:inputText id="id"
                           size="6"
                      maxlength="6"
                          value="#{tvProgramHome.instance.id}">
                    <a:support event="onblur" reRender="idField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="endDateTimeField" template="layout/edit.xhtml">
                <ui:define name="label">End date time</ui:define>
                <rich:calendar id="endDateTime"
                          value="#{tvProgramHome.instance.endDateTime}" datePattern="MM/dd/yyyy hh:mm a"/>
            </s:decorate>

            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{tvProgramHome.persist}"
                       disabled="#{!tvProgramHome.wired}"
                       rendered="#{!tvProgramHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{tvProgramHome.update}"
                       rendered="#{tvProgramHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{tvProgramHome.remove}"
                      immediate="true"
                       rendered="#{tvProgramHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/TvProgram.xhtml"
                rendered="#{tvProgramHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty tvProgramFrom ? 'TvProgramList' : tvProgramFrom}.xhtml"
                rendered="#{!tvProgramHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Channels *" labelClass="required">
    <div class="association" id="channelsParent">

        <h:outputText value="There is no channels associated with this tvProgram."
                   rendered="#{tvProgramHome.instance.channels == null}"/>

        <rich:dataTable var="_channels"
                   value="#{tvProgramHome.instance.channels}"
                rendered="#{tvProgramHome.instance.channels != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="channelsTable">
            <h:column>
                <f:facet name="header">Epg pos</f:facet>
                <h:outputText value="#{_channels.epgPos}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Name</f:facet>
                <h:outputText value="#{_channels.name}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Image</f:facet>
                <h:outputText value="#{_channels.image}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Favourite</f:facet>
                <h:outputText value="#{_channels.favourite}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Channel sigla</f:facet>
                <h:outputText value="#{_channels.channelSigla}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{tvProgramHome.instance.channels != null ? 'changeParent' : 'selectParent'}" value="#{tvProgramHome.instance.channels != null ? 'Change' : 'Select'} channels"
                       view="/ChannelsList.xhtml">
                <f:param name="from" value="TvProgramEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
